package com.hwangrq.service.impl;

import com.hwangrq.service.WorkService;

import java.util.concurrent.TimeUnit;

/**
 * 随机睡眠 0-100ms
 * @author hwangrq
 */
public class WorkServiceImpl implements WorkService {

    @Override
    public String methodA(int timeout) {
        sleep(timeout);
        return "methodA";
    }

    @Override
    public String methodB(int timeout) {
        sleep(timeout);
        return "methodB";
    }

    @Override
    public String methodC(int timeout) {
        sleep(timeout);
        return "methodC";
    }

    // 随机休眠0-100ms
    public void sleep(int timeout){
        try {
            TimeUnit.MILLISECONDS.sleep(timeout);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
